<template>
  <div class="newsInfo-container">
        <h1 class="title">{{newsInfo.title}}</h1>
        <p class="newsInfo-nav">
            <span>发表时间: {{newsInfo.add_time}}</span>
            <span>点击: {{newsInfo.click}}次</span>
        </p>
        <div class="content" v-html="newsInfo.content"></div>
    </div>
</template>

<script>
export default {
  data() {
    return {
      newsInfo: {}
    }
  },
  created() {
    this.getNewsInfo()
  },
  methods: {
    // 获取新闻详情
    getNewsInfo() {
      this.$http.get('news/show',{params: {id: this.$route.params.id}}).then(res => {
        // 这里变成 0 是成功了
        if (res.data.status === 0) {
          this.newsInfo = res.data.message[0]
          console.log(this.newsInfo);
          
        } else {
          this.$toast('新闻资讯获取失败')
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.newsInfo-container {
    padding: 10px;
    text-align: left;
    .title {
        font-size: 18px;
        margin: 10px 0;
        color: orangered;
    }
    .newsInfo-nav {
        display: flex;
        justify-content: space-between;
        color: #26a2ff;
        border-bottom: 1px solid #ccc;
    }
    .content {
        img {
            width: 100%;
        }
    }
}
</style>